import 'package:flutter/material.dart';

main() {
  runApp(const MaterialApp(home: StatefulHome()));
}

// 定义有状态控件
class StatefulHome extends StatefulWidget {
  const StatefulHome({super.key});

  @override
  State<StatefulHome> createState() => _HomeState();
}

// 定义状态类
class _HomeState extends State<StatefulHome> {
  var count = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("Stateful"),
        backgroundColor: Colors.cyan,
      ),
      body: Center(
        child: Text(
          'Counter: $count',
          style: const TextStyle(fontSize: 24),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          print('ADD one');
          setState(() {
            count++;
          });
        },
        child: const Icon(Icons.add),
      ),
    );
  }
}
